import JSEncrypt from 'jsencrypt/bin/jsencrypt'

// 密钥对生成 http://web.chacuo.net/netrsakeypair

const publicKey = 'MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAnNUMyBN5PPjmgMScXQLg8ejLnF6N2bv9K7XxnGwE7NrKKSKE0i06/T3QQeuqIkMEggqcB3G5H+pNUxKltfBuQ87uqivfpQ+ISeRn6x1ujiKOSWK8mzSMaulGtQzARz55Vxq5+cKkoVMnKrTUr3WJgLswEW3w8BM+lLBaxUQVEKBNRKW4Tx4DSJq4u3GDZAKjURXh07O/x0kXZ7aAQxkvlbmlmB45xv0iJNW7FcS8rsU63ndOKvyV0gSS+0+1ypBGDGZnnqJUES8vn3woS6xZpeYAgiYQhOBeuK9A9QGkOhQL4ao+EOambMd48S9wtAOO+aI/i0E21jzZ9cHeX1gO9wIDAQAB'

const privateKey = ''

// 加密
export function encrypt(txt) {
  const encryptor = new JSEncrypt()
  encryptor.setPublicKey(publicKey) // 设置公钥
  return encryptor.encrypt(txt) // 对数据进行加密
}

// 解密
export function decrypt(txt) {
  const encryptor = new JSEncrypt()
  encryptor.setPrivateKey(privateKey) // 设置私钥
  return encryptor.decrypt(txt) // 对数据进行解密
}
